package com.hrp.book.base

import android.app.Application
import android.content.Context
import com.blankj.utilcode.util.LogUtils
import com.hrp.analyzer.AnalyzerManager
import com.hrp.analyzer.core.helper.DebugHelper
import com.hrp.analyzer.util.compat.SimpleLogAdapter

class BaseApp : Application() {

    companion object {
        private lateinit var application: Application

        fun getContext(): Context {
            return application
        }

    }

    override fun onCreate() {
        super.onCreate()
        application = this
        DebugHelper.subscribe {
            LogUtils.getConfig().stackOffset = 7
            LogUtils.e("test_", it)
            LogUtils.getConfig().stackOffset = 0
        }
        AnalyzerManager.setDelegate(object : SimpleLogAdapter() {
            override fun log(level: Int, message: String, throwable: Throwable?) {
                LogUtils.getConfig().stackOffset = 2
                if (throwable != null) {
                    LogUtils.log(level, "test_", message, throwable)
                } else {
                    LogUtils.log(level, "test_", message)
                }
                LogUtils.getConfig().stackOffset = 0
            }

        })
    }


}